<!-- Note: All the codes inside the <table> tag are important for restoring the current values. Dont change anything. -->
<h1>List of Electives</h1>
<?php echo "<b> Curriculum: " . $curr . "</b>"; ?> </br></br>

<div id="electives">
	<?php echo form_open('encoder/electives'); ?>
	
	<?php echo '<b><i>' . form_label('Computer Science') . '</i></b>';?>
	<table>
		<?php 
			$ctr = 0;
			echo "<tr>";
			foreach($e_cs as $item){
				if($ctr != 2){	//To setup how many checkboxes are there in a row.
					if($curr_elective != NULL){ //If some Electives are already selected
						foreach($curr_elective as $i){	//Compare the currently selected electives to the checkbox to be echoed.
							if($i == $item){	//If equal, set it to checked.
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
									'checked' => TRUE,
								);
								break;
							}else{
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
							}
						}	
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}else{	//If there are still no Electives selected
						$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}
					$ctr = $ctr+1;
				}else{
					if($curr_elective != NULL){ //If some Electives are already selected
						foreach($curr_elective as $i){	//Compare the currently selected electives to the checkbox to be echoed.
							if($i == $item){	//If equal, set it to checked.
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
									'checked' => TRUE,
								);
								break;
							}else{
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
							}
						}	
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}else{	//If there are still no Electives selected
						$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}
					echo "</tr>";
					echo "<tr>";
					$ctr = 0;
				}
			}
		?>
	</table>
	</br>
	
	<?php echo '<b><i>' . form_label('Applied Mathematics') . '</i></b>';?>
	<table>
		<?php 
			$ctr = 0;
			echo "<tr>";
			foreach($e_am as $item){
				if($ctr != 2){	//To setup how many checkboxes are there in a row.
					if($curr_elective != NULL){ //If some Electives are already selected
						foreach($curr_elective as $i){	//Compare the currently selected electives to the checkbox to be echoed.
							if($i == $item){	//If equal, set it to checked.
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
									'checked' => TRUE,
								);
								break;
							}else{
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
							}
						}	
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}else{	//If there are still no Electives selected
						$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}
					$ctr = $ctr+1;
				}else{
					if($curr_elective != NULL){ //If some Electives are already selected
						foreach($curr_elective as $i){	//Compare the currently selected electives to the checkbox to be echoed.
							if($i == $item){	//If equal, set it to checked.
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
									'checked' => TRUE,
								);
								break;
							}else{
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
							}
						}	
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}else{	//If there are still no Electives selected
						$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}
					echo "</tr>";
					echo "<tr>";
					$ctr = 0;
				}
			}
		?>
	</table>
	</br>
	
	<?php echo '<b><i>' . form_label('Developmant Communication') . '</i></b>';?>
	<table>
		<?php 
			$ctr = 0;
			echo "<tr>";
			foreach($e_dc as $item){
				if($ctr != 2){	//To setup how many checkboxes are there in a row.
					if($curr_elective != NULL){ //If some Electives are already selected
						foreach($curr_elective as $i){	//Compare the currently selected electives to the checkbox to be echoed.
							if($i == $item){	//If equal, set it to checked.
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
									'checked' => TRUE,
								);
								break;
							}else{
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
							}
						}	
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}else{	//If there are still no Electives selected
						$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}
					$ctr = $ctr+1;
				}else{
					if($curr_elective != NULL){ //If some Electives are already selected
						foreach($curr_elective as $i){	//Compare the currently selected electives to the checkbox to be echoed.
							if($i == $item){	//If equal, set it to checked.
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
									'checked' => TRUE,
								);
								break;
							}else{
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
							}
						}	
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}else{	//If there are still no Electives selected
						$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}
					echo "</tr>";
					echo "<tr>";
					$ctr = 0;
				}
			}
		?>
	</table>
	</br>
	
	<?php echo '<b><i>' . form_label('Economics and Management') . '</i></b>';?>
	<table>
		<?php 
			$ctr = 0;
			echo "<tr>";
			foreach($e_em as $item){
				if($ctr != 2){	//To setup how many checkboxes are there in a row.
					if($curr_elective != NULL){ //If some Electives are already selected
						foreach($curr_elective as $i){	//Compare the currently selected electives to the checkbox to be echoed.
							if($i == $item){	//If equal, set it to checked.
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
									'checked' => TRUE,
								);
								break;
							}else{
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
							}
						}	
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}else{	//If there are still no Electives selected
						$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}
					$ctr = $ctr+1;
				}else{
					if($curr_elective != NULL){ //If some Electives are already selected
						foreach($curr_elective as $i){	//Compare the currently selected electives to the checkbox to be echoed.
							if($i == $item){	//If equal, set it to checked.
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
									'checked' => TRUE,
								);
								break;
							}else{
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
							}
						}	
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}else{	//If there are still no Electives selected
						$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}
					echo "</tr>";
					echo "<tr>";
					$ctr = 0;
				}
			}
		?>
	</table>
	</br>
	
	<?php echo '<b><i>' . form_label('Humanities') . '</i></b>';?>
	<table>
		<?php 
			$ctr = 0;
			echo "<tr>";
			foreach($e_hum as $item){
				if($ctr != 2){	//To setup how many checkboxes are there in a row.
					if($curr_elective != NULL){ //If some Electives are already selected
						foreach($curr_elective as $i){	//Compare the currently selected electives to the checkbox to be echoed.
							if($i == $item){	//If equal, set it to checked.
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
									'checked' => TRUE,
								);
								break;
							}else{
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
							}
						}	
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}else{	//If there are still no Electives selected
						$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}
					$ctr = $ctr+1;
				}else{
					if($curr_elective != NULL){ //If some Electives are already selected
						foreach($curr_elective as $i){	//Compare the currently selected electives to the checkbox to be echoed.
							if($i == $item){	//If equal, set it to checked.
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
									'checked' => TRUE,
								);
								break;
							}else{
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
							}
						}	
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}else{	//If there are still no Electives selected
						$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}
					echo "</tr>";
					echo "<tr>";
					$ctr = 0;
				}
			}
		?>
	</table>
	</br>
	
	<?php echo '<b><i>' . form_label('Forestry Resource Management ') . '</i></b>';?>
	<table>
		<?php 
			$ctr = 0;
			echo "<tr>";
			foreach($e_frm as $item){
				if($ctr != 2){	//To setup how many checkboxes are there in a row.
					if($curr_elective != NULL){ //If some Electives are already selected
						foreach($curr_elective as $i){	//Compare the currently selected electives to the checkbox to be echoed.
							if($i == $item){	//If equal, set it to checked.
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
									'checked' => TRUE,
								);
								break;
							}else{
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
							}
						}	
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}else{	//If there are still no Electives selected
						$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}
					$ctr = $ctr+1;
				}else{
					if($curr_elective != NULL){ //If some Electives are already selected
						foreach($curr_elective as $i){	//Compare the currently selected electives to the checkbox to be echoed.
							if($i == $item){	//If equal, set it to checked.
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
									'checked' => TRUE,
								);
								break;
							}else{
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
							}
						}	
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}else{	//If there are still no Electives selected
						$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}
					echo "</tr>";
					echo "<tr>";
					$ctr = 0;
				}
			}
		?>
	</table>
	</br>
	
	<?php echo '<b><i>' . form_label('Physics') . '</i></b>';?>
	<table>
		<?php 
			$ctr = 0;
			echo "<tr>";
			foreach($e_p as $item){
				if($ctr != 2){	//To setup how many checkboxes are there in a row.
					if($curr_elective != NULL){ //If some Electives are already selected
						foreach($curr_elective as $i){	//Compare the currently selected electives to the checkbox to be echoed.
							if($i == $item){	//If equal, set it to checked.
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
									'checked' => TRUE,
								);
								break;
							}else{
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
							}
						}	
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}else{	//If there are still no Electives selected
						$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}
					$ctr = $ctr+1;
				}else{
					if($curr_elective != NULL){ //If some Electives are already selected
						foreach($curr_elective as $i){	//Compare the currently selected electives to the checkbox to be echoed.
							if($i == $item){	//If equal, set it to checked.
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
									'checked' => TRUE,
								);
								break;
							}else{
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
							}
						}	
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}else{	//If there are still no Electives selected
						$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}
					echo "</tr>";
					echo "<tr>";
					$ctr = 0;
				}
			}
		?>
	</table>
	</br>
	
	<?php echo '<b><i>' . form_label('Social Science') . '</i></b>';?>
	<table>
		<?php 
			$ctr = 0;
			echo "<tr>";
			foreach($e_ss as $item){
				if($ctr != 2){	//To setup how many checkboxes are there in a row.
					if($curr_elective != NULL){ //If some Electives are already selected
						foreach($curr_elective as $i){	//Compare the currently selected electives to the checkbox to be echoed.
							if($i == $item){	//If equal, set it to checked.
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
									'checked' => TRUE,
								);
								break;
							}else{
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
							}
						}	
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}else{	//If there are still no Electives selected
						$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}
					$ctr = $ctr+1;
				}else{
					if($curr_elective != NULL){ //If some Electives are already selected
						foreach($curr_elective as $i){	//Compare the currently selected electives to the checkbox to be echoed.
							if($i == $item){	//If equal, set it to checked.
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
									'checked' => TRUE,
								);
								break;
							}else{
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
							}
						}	
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}else{	//If there are still no Electives selected
						$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}
					echo "</tr>";
					echo "<tr>";
					$ctr = 0;
				}
			}
		?>
	</table>
	</br>
	
	<?php echo '<b><i>' . form_label('Statistics') . '</i></b>';?>
	<table>
		<?php 
			$ctr = 0;
			echo "<tr>";
			foreach($e_stat as $item){
				if($ctr != 2){	//To setup how many checkboxes are there in a row.
					if($curr_elective != NULL){ //If some Electives are already selected
						foreach($curr_elective as $i){	//Compare the currently selected electives to the checkbox to be echoed.
							if($i == $item){	//If equal, set it to checked.
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
									'checked' => TRUE,
								);
								break;
							}else{
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
							}
						}	
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}else{	//If there are still no Electives selected
						$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}
					$ctr = $ctr+1;
				}else{
					if($curr_elective != NULL){ //If some Electives are already selected
						foreach($curr_elective as $i){	//Compare the currently selected electives to the checkbox to be echoed.
							if($i == $item){	//If equal, set it to checked.
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
									'checked' => TRUE,
								);
								break;
							}else{
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
							}
						}	
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}else{	//If there are still no Electives selected
						$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}
					echo "</tr>";
					echo "<tr>";
					$ctr = 0;
				}
			}
		?>
	</table>
	
	</br>
	
	<?php echo '<b><i>' . form_label('Industrial Engineering') . '</i></b>';?>
	<table>
		<?php 
			$ctr = 0;
			echo "<tr>";
			foreach($e_ie as $item){
				if($ctr != 2){	//To setup how many checkboxes are there in a row.
					if($curr_elective != NULL){ //If some Electives are already selected
						foreach($curr_elective as $i){	//Compare the currently selected electives to the checkbox to be echoed.
							if($i == $item){	//If equal, set it to checked.
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
									'checked' => TRUE,
								);
								break;
							}else{
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
							}
						}	
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}else{	//If there are still no Electives selected
						$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}
					$ctr = $ctr+1;
				}else{
					if($curr_elective != NULL){ //If some Electives are already selected
						foreach($curr_elective as $i){	//Compare the currently selected electives to the checkbox to be echoed.
							if($i == $item){	//If equal, set it to checked.
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
									'checked' => TRUE,
								);
								break;
							}else{
								$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
							}
						}	
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}else{	//If there are still no Electives selected
						$data = array(
									'name' => 'electives[]',
									'value' => $item,
								);
						echo "<td width=120>" . form_checkbox($data) . form_label($item) . "</td>";
					}
					echo "</tr>";
					echo "<tr>";
					$ctr = 0;
				}
			}
		?>
	</table>
	
	<?php echo form_error('electivesform'); ?>
	<?php echo form_error('electivesformcurr'); ?>
</div>

<!-- Submit Button -->
<?php
	$data = array(
		'value' => 'Save',
	); 
	echo form_submit($data);
?>
<?php echo form_close(); ?>
	
<!-- Cancel Button -->
<?php 
	echo form_open('encoder/view');
		
	$data = array(
		'value' => 'Cancel',
	); 
	echo form_submit($data);
	echo form_close();
?>
<?php echo anchor('encoder/clearElectives/','Delete All Approved Electives');?>
	</br>
<?php echo anchor('encoder/index','Back to Home Page');?> </br>
<?php echo anchor('encoder/logout','Logout');?>